/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fri.entiry;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author NguyenDongUIT
 */
@Entity
@Table(name = "fr_usermoney")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "FrUsermoney.findAll", query = "SELECT f FROM FrUsermoney f"),
    @NamedQuery(name = "FrUsermoney.findByIdUserMoney", query = "SELECT f FROM FrUsermoney f WHERE f.idUserMoney = :idUserMoney"),
    @NamedQuery(name = "FrUsermoney.findByVal", query = "SELECT f FROM FrUsermoney f WHERE f.val = :val"),
    @NamedQuery(name = "FrUsermoney.findByLastChanged", query = "SELECT f FROM FrUsermoney f WHERE f.lastChanged = :lastChanged")})
public class FrUsermoney implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 36)
    @Column(name = "IdUserMoney")
    private String idUserMoney;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Val")
    private float val;
    @Basic(optional = false)
    @NotNull
    @Column(name = "LastChanged")
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastChanged;
    @JoinColumn(name = "UserId", referencedColumnName = "UserId")
    @ManyToOne(optional = false)
    private FrUser userId;
    @JoinColumn(name = "CurrencyId", referencedColumnName = "CurrencyId")
    @ManyToOne(optional = false)
    private FrCurrency currencyId;

    public FrUsermoney() {
    }

    public FrUsermoney(String idUserMoney) {
        this.idUserMoney = idUserMoney;
    }

    public FrUsermoney(String idUserMoney, float val, Date lastChanged) {
        this.idUserMoney = idUserMoney;
        this.val = val;
        this.lastChanged = lastChanged;
    }

    public String getIdUserMoney() {
        return idUserMoney;
    }

    public void setIdUserMoney(String idUserMoney) {
        this.idUserMoney = idUserMoney;
    }

    public float getVal() {
        return val;
    }

    public void setVal(float val) {
        this.val = val;
    }

    public Date getLastChanged() {
        return lastChanged;
    }

    public void setLastChanged(Date lastChanged) {
        this.lastChanged = lastChanged;
    }

    public FrUser getUserId() {
        return userId;
    }

    public void setUserId(FrUser userId) {
        this.userId = userId;
    }

    public FrCurrency getCurrencyId() {
        return currencyId;
    }

    public void setCurrencyId(FrCurrency currencyId) {
        this.currencyId = currencyId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idUserMoney != null ? idUserMoney.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FrUsermoney)) {
            return false;
        }
        FrUsermoney other = (FrUsermoney) object;
        if ((this.idUserMoney == null && other.idUserMoney != null) || (this.idUserMoney != null && !this.idUserMoney.equals(other.idUserMoney))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fri.entiry.FrUsermoney[ idUserMoney=" + idUserMoney + " ]";
    }
    
}
